//
//  LGFollowNavigationView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/28.
//

#import "LGFollowNavigationView.h"

@interface LGFollowNavigationView()

/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
/**   */
@property (nonatomic , strong)UIView *statusView;
/**   */
@property (nonatomic , strong)UIButton *typeBtn;
/**   */
@property (nonatomic , strong)UILabel *unitLabel;
/**   */
@property (nonatomic , strong)UIImageView *statusTip;

@end

@implementation LGFollowNavigationView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.nameLabel.text = title;
}

-(void)setAgeString:(NSString *)ageString{
    _ageString = ageString;
    if([ageString stringByReplacingOccurrencesOfString:@" " withString:@""].length > 0){
        self.tipView.hidden = NO;
    }else{
        self.tipView.hidden = YES;
    }
    self.ageLabel.text = ageString;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.backBtn];
    [self addSubview:self.nameLabel];
    [self addSubview:self.ageLabel];
    [self addSubview:self.tipView];
    [self addSubview:self.patientBtn];
    [self addSubview:self.finishBtn];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.ageLabel.mas_top).offset(-3);
        make.centerX.equalTo(self);
    }];
    [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-5);
        make.centerX.equalTo(self);
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(5);
        make.centerY.equalTo(self.nameLabel.mas_bottom);
        make.width.height.equalTo(@(12));
    }];
    [self.patientBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel).offset(-viewPix(16));
        make.right.equalTo(self.nameLabel).offset(viewPix(20));
        make.top.equalTo(self.nameLabel);
        make.bottom.equalTo(self.ageLabel);
    }];
    
}
-(UIButton *)backBtn{
    if(!_backBtn){
        _backBtn= [UIButton buttonWithType:UIButtonTypeCustom];
        _backBtn.frame = CGRectMake(5, statusBarHeight, 44, 44);
        [_backBtn setImage:kNavBackImage forState:UIControlStateNormal];
        [_backBtn setImage:kNavBackImage forState:UIControlStateHighlighted];
    }
    return _backBtn;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@" " colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightSemibold) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@" " colorString:@"#999999" textFont:LGFont(13) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _ageLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"聊天咨询-查看患者"]];
    }
    return _tipView;
}

-(UIButton *)patientBtn{
    if(!_patientBtn){
        _patientBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _patientBtn;
}

-(UIButton *)finishBtn{
    if(!_finishBtn){
        _finishBtn = [UIButton buttonWithTitle:@"完成随访" titleFont:LGFontWeight(14, UIFontWeightMedium) textColor:@"#429BFF" imageName:@""];
        _finishBtn.frame = CGRectMake(Screen_W-76, statusBarHeight, 60, 44);
    }
    return _finishBtn;
}

@end
